{* $Id$ *}
{include_core file="admin/lib/header.html" title="掌柜端迁移"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left"><span>先搜索出要迁移的门店，选择门店，填入要迁移到的合伙人手机号码，点击确认迁移!</span></h2>
    <!--  <a href="{AnUrl('store/admin?is_delete=1')}" class="btn btn-default btn-sm right">&lt; 返回掌柜门店列表</a> -->
  </div>

  <div class="search-form js_advancedForm">
    <form action="store/admin/move" method="get" class="js_focusSearchForm">
      <input type="hidden" name="is_advenced" value="1">
      <input type="hidden" name="is_delete" value="{$is_delete}">
      <input type="hidden" name="status" value="{$status}">
      <p>
        <label for="" class="search-f-label">合伙人手机号：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[mobile]" value="{$search_filter.mobile}">
      </p>
      <p>
        <label for="" class="search-f-label">掌柜端手机号：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[store_mobile]" value="{$search_filter.store_mobile}">
      </p>
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>

  <!--start:列表-->
  <table class="list-table">
    <thead><tr>
      <!-- {if $status == 1}
      <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
      {/if} -->
      <th style="min-width:60px;">选择</th>
      <th style="min-width:200px;">掌柜信息</th>
      <th style="min-width:60px;">签约时间</th>
    </tr></thead>
    <tbody>
      {foreach $store_list as $k=>$v}
        {if $v.agency_id != 0}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
         <td><input type="checkbox" class="listSelect" value="{$v.user_info.id}"></td>
          <td>
          店铺名称：{$v.title}{$v.title_branch}<br/>
          店长手机号：{$v.user_info.mobile}<br/>
          
          合伙人姓名：{$v.agency_user_info.realname}<br/>
          合伙人手机号：{$v.agency_user_info.mobile}<br/>
          
          市场人员姓名：{$v.market_user_info.realname}<br/>
          市场人员手机号：{$v.market_user_info.mobile}<br/>
          
          </td>
          <td>{time_format($v.add_time)}</td>
        </tr>
        {/if}
      {foreachelse}
          <tr><td class="txtleft" colspan="6">暂无数据</td></tr>
      {/foreach}
    </tbody>
    <tfoot>
        <tr >
            <td><input type="checkbox" class="selectAll">全选</td><td colspan="6"> 目标合伙人手机号：<input type="text" value="" class="search-f-ipt1" id="agencyId" value=""> <a href="javascript:void(0);" class="btn btn-default btn-xs jsMove">批量迁移</a></td>
        </tr>
    </tfoot>
  </table>
  <script type="text/javascript">

  $(function(){
      $('.jsMove').click(function(){
          
          var url = "{AnUrl('store/admin/move/save_agency')}";
          var descMobile = $('#agencyId').val();
          var selectStore = $('.listSelect:checked');
          var params = {};
          
          {literal}
          var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
          {/literal}
          if(!myreg.test(descMobile)) {
              alert('请输入有效的手机号码！');
              return false;
          } 
          
          params.desc_mobile = descMobile;
          params.owner_ids = [];
          
          if (selectStore.length == 0) {
              alert('请选择要迁移的门店！');
              return false;
          }
          
          $.each(selectStore, function(k, v) {
              params.owner_ids.push($(v).val())
          })
          
          $.post(url, params, function(json){
              if (json.info == 'ok') {
                  showMsg(json.msg, 1, 1, 1, function(){
                      selectStore.closest("tr").fadeOut(function(){
                          $(this).remove();
                       });
                  });
              } else {
                  showMsg(json.info, 0);
              }
          }, 'json');
          
      })
  });
  </script>

  {include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}